package com.java46.carera.reservationrecord.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.java46.carera.base.entity.JsonResult;
import com.java46.carera.base.entity.ReservationRecord;
import com.java46.carera.base.exception.BusinessException;
import com.java46.carera.reservationrecord.service.ReservationRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @ClassName ReservationRecordController
 * @Description 预约Controller
 * @Author c
 * @Date 2018/8/22 18:57
 * @Vcrsion 1.0
 **/
@Controller
@RequestMapping("/ReservationRecord")
public class ReservationRecordController {
    @Autowired
    private ReservationRecordService reservationRecordService;

    @RequestMapping("/add")
    @ResponseBody
    public JsonResult addReservationRecord(ReservationRecord reservationRecord){
        reservationRecord.setRestime(new Date());
        return reservationRecordService.addReservationRecord(reservationRecord);
    }

    @RequestMapping("/mod")
    @ResponseBody
    public JsonResult modReservationRecord(ReservationRecord reservationRecord){
        return reservationRecordService.modReservationRecord(reservationRecord);
    }

    @RequestMapping("/updateByStatus")
    @ResponseBody
    public JsonResult updateByStatus(Integer resid){
        return reservationRecordService.updateByStatus(resid);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public JsonResult deleteReservationRecord(Integer resid){
        return reservationRecordService.deleteReservationRecord(resid);
    }

    @RequestMapping("/queryAll")
    @ResponseBody
    public JsonResult queryAll(String keyword, Integer pageNum){
        return reservationRecordService.queryAll(keyword, pageNum);
    }

    @RequestMapping("/queryById")
    @ResponseBody
    public JsonResult queryById(Integer resid){
        return reservationRecordService.queryById(resid);
    }


}
